
In this tutorial, we will learn How to Records insert, update & delete from database table in SQL server database?
Let's see how we can do that
syntax for inserting a new record to a table :
INSERT INTO table_name (Column1, Column2, ...)
VALUES (value1, value2, ...);
Example:
Use abctutorial /*Use Your_database_name*/
INSERT INTO Users(UserName,UserMobileNo,UserEmail,UserAddress)
VALUES ('jony', '017XXXX','j011@gmail.com','USA');
You can also insert multiple records at the same time syntax is:
INSERT INTO table_name (field1, field2, ...)
VALUES (value3, value4, ...),
(value5, value6, ...),
(value7, value8, ...);
Example :
Use abctutorial /*Use Your_database_name*/
INSERT INTO Users(UserName,UserMobileNo,UserEmail,UserAddress)
VALUES ('Pony', '019XXXX','p011@gmail.com','Dhaka,Bangladesh'),
('Rony', '018XXXX','r011@gmail.com','Dhaka,Bangladesh'),
('Jon', '016XXXX','jon011@gmail.com','Dhaka,Bangladesh')
syntax for update a record to a table:
UPDATE table_name
SET column1 = a,
column2 = b
WHERE column3 = c;
Example:
Use abctutorial /*Use Your_database_name*/
UPDATE Users
SET UserName = 'Don',
UserMobileNo = '01999XXXX'
WHERE UserEmail = 'r011@gmail.com';
syntax for delete a record to a table :
DELETE FROM table_name
WHERE field1 = Z;
Example:
DELETE FROM Users
WHERE UserEmail = 'r011@gmail.com'